package com.minelx.scriptbuilder.script.attribute.clazz;

import com.minelx.scriptbuilder.parse.annotation.AnnotatedClassParser;
import com.minelx.scriptbuilder.script.attribute.function.Function;
import com.minelx.scriptbuilder.script.attribute.function.Params;
import com.minelx.scriptbuilder.script.attribute.value.Attribute;
import com.minelx.scriptbuilder.script.attribute.value.IAttribute;

import java.util.Map;

public class Class extends Attribute {

	@Override
	public IAttribute execute(Params params) {
		Attribute instance = new Attribute();
		for (Map.Entry<String, IAttribute> attribute : children.entrySet()) {
			instance.set(attribute.getKey(), attribute.getValue());
		}

		// init function
		instance.value("init", Function.doNothing()).execute(params);
		return instance;
	}

	@Override
	public String asString() {
		return "class";
	}

	public static IAttribute stringClass() {
		return new AnnotatedClassParser().parse(new StringClass()).getAttribute();
	}
}
